package com.star.warmwinter.common;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.star.warmwinter.R;
import com.star.warmwinter.util.ActivityManage;
import com.star.tool.util.StatusBarUtil;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

/**
 * Author: blackbai11
 * Date: 2016/2/18 10:11
 * Description: Activity基类
 */
public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityManage.push(this);
        bindLayout();
        StatusBarUtil.setLightMode(this);
        StatusBarUtil.setColor(this,getResources().getColor(R.color.colorPrimary),0);
        doBusiness();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ActivityManage.remove(this);
    }

    //绑定布局
    public abstract void bindLayout();

    //业务操作
    public abstract void doBusiness();

    //Rx订阅事件
    CompositeDisposable mCompositeDisposable;
    public void addDisposable(Disposable d){
        if(mCompositeDisposable == null){
            mCompositeDisposable = new CompositeDisposable();
        }
        mCompositeDisposable.add(d);
    }
}
